package com.jk.smartelderlycare.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jk.smartelderlycare.dao.SysLabelMapper;
import com.jk.smartelderlycare.dto.SysLabel;
import com.jk.smartelderlycare.pojo.PagedResponse;
import com.jk.smartelderlycare.service.SysLabelService;
import com.jk.smartelderlycare.utils.PaginationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author hhk
 * @version 1.0
 * @ClassName SysLabelServiceImpl
 * @program: smart-elderly-care
 * @description: TODO
 * @date 2024/11/14 14:53
 */
@Service
public class SysLabelServiceImpl implements SysLabelService {
    @Autowired
    private SysLabelMapper sysLabelMapper;
    /**
     * @description: 标签后端分页查询
     * @param: [sysLabel, pageNum, pageSize]
     * @return: com.jk.smartelderlycare.pojo.PagedResponse<com.jk.smartelderlycare.dto.SysLabel>
     * @author hhk
     * @date: 2024/11/14 14:54
     */
    @Override
    public PagedResponse<SysLabel> findSysLabelPagimationList(SysLabel sysLabel, Integer pageNum, Integer pageSize) {
        Page<SysLabel> page = new Page<>(pageNum,pageSize);
        IPage<SysLabel> sysLabelIPage =sysLabelMapper.findSysLabelPagimationList(sysLabel,page);
        return PaginationUtil.getPagedResponse(sysLabelIPage.getRecords(),pageNum,pageSize,sysLabelIPage.getTotal());
    }
    /**
     * @description: 新增
     * @param: [sysLabel]
     * @return: void
     * @author hhk
     * @date: 2024/11/14 14:57
     */
    @Override
    public void addSysLabel(SysLabel sysLabel) {
        sysLabelMapper.insert(sysLabel);
    }
    /**
     * @description: 根据id删除
     * @param: [labelId]
     * @return: void
     * @author hhk
     * @date: 2024/11/14 14:58
     */
    @Override
    public void deleteSysLabelByLabelId(Long labelId) {
        sysLabelMapper.deleteById(labelId);
        sysLabelMapper.deleteLabelAndTutionByLabelId(labelId);
    }
    /**
     * @description: 根据id回显数据
     * @param: []
     * @return: com.jk.smartelderlycare.dto.SysLabel
     * @author hhk
     * @date: 2024/11/14 14:59
     */
    @Override
    public SysLabel findSysLabelByLabelId(Long labelId) {
        return sysLabelMapper.selectById(labelId);
    }
    /**
     * @description: 修改
     * @param: [sysLabel]
     * @return: void
     * @author hhk
     * @date: 2024/11/14 15:00
     */
    @Override
    public void updataSysLabel(SysLabel sysLabel) {
        sysLabelMapper.updateById(sysLabel);
    }
    /**
     * @description: 状态修改
     * @param: [sysLabel]
     * @return: void
     * @author hhk
     * @date: 2024/11/14 16:01
     */
    @Override
    public void updateStatus(SysLabel sysLabel) {
        sysLabelMapper.updateStatus(sysLabel);
    }
}
